<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    <title>zxing后台二维码生成和解析类库 | 尼古拉斯-鱼丸博客 | 喝酒、吃肉、不赌</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="二维码,ZXing">
    <meta name="description" content="Google二维码生成解析项目Zxing什么Zxing？  ZXing是一个开源Java类库用于解析多种格式的1D/2D条形码。目标是能够对QR编码、Data Matrix、UPC的1D条形码进行解码。 其提供了多种平台下的客户端包括：J2ME、J2SE和Android。 Zxing使用依赖1234567891011&amp;lt;dependency&amp;gt;   &amp;lt;groupId&amp;gt;com.g">
<meta name="keywords" content="二维码,ZXing">
<meta property="og:type" content="article">
<meta property="og:title" content="zxing后台二维码生成和解析类库">
<meta property="og:url" content="http://fish_08.oschina.io/2017/06/23/QRcode/index.html">
<meta property="og:site_name" content="尼古拉斯-鱼丸博客">
<meta property="og:description" content="Google二维码生成解析项目Zxing什么Zxing？  ZXing是一个开源Java类库用于解析多种格式的1D/2D条形码。目标是能够对QR编码、Data Matrix、UPC的1D条形码进行解码。 其提供了多种平台下的客户端包括：J2ME、J2SE和Android。 Zxing使用依赖1234567891011&amp;lt;dependency&amp;gt;   &amp;lt;groupId&amp;gt;com.g">
<meta property="og:updated_time" content="2017-06-28T08:16:51.528Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="zxing后台二维码生成和解析类库">
<meta name="twitter:description" content="Google二维码生成解析项目Zxing什么Zxing？  ZXing是一个开源Java类库用于解析多种格式的1D/2D条形码。目标是能够对QR编码、Data Matrix、UPC的1D条形码进行解码。 其提供了多种平台下的客户端包括：J2ME、J2SE和Android。 Zxing使用依赖1234567891011&amp;lt;dependency&amp;gt;   &amp;lt;groupId&amp;gt;com.g">
    
        <link rel="alternative" href="/atom.xml" title="尼古拉斯-鱼丸博客" type="application/atom+xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="/css/style.css?v=1.6.7">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">于亮</h5>
          <a href="mailto:136214289@qq.com" title="136214289@qq.com" class="mail">136214289@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                文档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://git.oschina.net/fish_08" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://weibo.com/2837335591/profile?rightmod=1&wvr=6&mod=personinfo" target="_blank" >
                <i class="icon icon-lg icon-weibo"></i>
                Weibo
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/custom"  >
                <i class="icon icon-lg icon-link"></i>
                测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">zxing后台二维码生成和解析类库</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">zxing后台二维码生成和解析类库</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-06-23T02:55:05.000Z" itemprop="datePublished" class="page-time">
  2017-06-23
</time>


            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Google二维码生成解析项目Zxing"><span class="post-toc-number">1.</span> <span class="post-toc-text">Google二维码生成解析项目Zxing</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#什么Zxing？"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">什么Zxing？</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Zxing使用依赖"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">Zxing使用依赖</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#简单二维码生成工具类SimpleQRCodeUtil"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">简单二维码生成工具类SimpleQRCodeUtil</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#二维码中嵌入Logo生成工具类QRCodeUtil"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">二维码中嵌入Logo生成工具类QRCodeUtil</span></a></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-QRcode"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">zxing后台二维码生成和解析类库</h1>
        <div class="post-meta">
            <time class="post-time" title="2017年06月23日 10:55" datetime="2017-06-23T02:55:05.000Z"  itemprop="datePublished">2017-06-23</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="Google二维码生成解析项目Zxing"><a href="#Google二维码生成解析项目Zxing" class="headerlink" title="Google二维码生成解析项目Zxing"></a>Google二维码生成解析项目Zxing</h2><h3 id="什么Zxing？"><a href="#什么Zxing？" class="headerlink" title="什么Zxing？"></a>什么Zxing？</h3><p>  ZXing是一个开源Java类库用于解析多种格式的1D/2D条形码。目标是能够对QR编码、Data Matrix、UPC的1D条形码进行解码。 其提供了多种平台下的客户端包括：J2ME、J2SE和Android。</p>
<h3 id="Zxing使用依赖"><a href="#Zxing使用依赖" class="headerlink" title="Zxing使用依赖"></a>Zxing使用依赖</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">&lt;dependency&gt;</div><div class="line">   &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;</div><div class="line">   &lt;artifactId&gt;core&lt;/artifactId&gt;</div><div class="line">   &lt;version&gt;3.3.0&lt;/version&gt;</div><div class="line">&lt;/dependency&gt;</div><div class="line">&lt;dependency&gt;</div><div class="line">   &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;</div><div class="line">   &lt;artifactId&gt;javase&lt;/artifactId&gt;</div><div class="line">   &lt;version&gt;3.3.0&lt;/version&gt;</div><div class="line"> &lt;/dependency&gt;</div></pre></td></tr></table></figure>
<h3 id="简单二维码生成工具类SimpleQRCodeUtil"><a href="#简单二维码生成工具类SimpleQRCodeUtil" class="headerlink" title="简单二维码生成工具类SimpleQRCodeUtil"></a>简单二维码生成工具类SimpleQRCodeUtil</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div></pre></td><td class="code"><pre><div class="line"></div><div class="line"> /**</div><div class="line"> * 二维码生成工具类</div><div class="line"> * Created by yu on 2017/6/22.</div><div class="line"> */</div><div class="line">public class SimpleQRCodeUtil &#123;</div><div class="line"></div><div class="line">    // 日志处理</div><div class="line">    private  static   Logger logger = LoggerFactory.getLogger(SimpleQRCodeUtil.class);</div><div class="line"></div><div class="line">    //二维码颜色</div><div class="line">    private static final int BLACK = 0xFF000000;</div><div class="line"></div><div class="line">    //二维码颜色</div><div class="line">    private static final int WHITE = 0xFFFFFFFF;</div><div class="line"></div><div class="line">    /**</div><div class="line">     * 简单二维码创建</div><div class="line">     */</div><div class="line">    public static File createQrCode(int width,int height,String imageType,String content) &#123;</div><div class="line"></div><div class="line">        <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">            logger.debug(<span class="string">"SimpleQRCodeUtil-createQrCode-width:"</span>+width+<span class="string">" height:"</span>+height+<span class="string">" imageType:"</span>+imageType+<span class="string">" content:"</span>+content);</div><div class="line">        &#125;</div><div class="line">    /*    int width = 300;</div><div class="line">        int height = 300;</div><div class="line">        String formate = <span class="string">"png"</span>;</div><div class="line">        String content = <span class="string">"http://5sing.kugou.com/fc/13842393.html"</span>;*/</div><div class="line"></div><div class="line">        // 定义二维码参数</div><div class="line">        Map hints = new HashMap();</div><div class="line">        // 内容所使用字符集编码</div><div class="line">        hints.put(EncodeHintType.CHARACTER_SET,<span class="string">"utf-8"</span>);</div><div class="line">        // 指定纠错等级,纠错级别（L 7%、M 15%、Q 25%、H 30%）</div><div class="line">        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);</div><div class="line">        //设置二维码边的空度，非负数</div><div class="line">        hints.put(EncodeHintType.MARGIN,2);</div><div class="line">        //hints.put(EncodeHintType.MAX_SIZE, 350);//设置图片的最大值</div><div class="line">        //hints.put(EncodeHintType.MIN_SIZE, 100);//设置图片的最小值</div><div class="line"></div><div class="line"></div><div class="line">        // 生成二维码</div><div class="line">        try &#123;</div><div class="line">            BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE,width,height,hints);</div><div class="line">            File file = new File(<span class="string">"D:/QRcode/fish/index.png"</span>);</div><div class="line">            MatrixToImageWriter.writeToFile(bitMatrix,imageType,file);</div><div class="line">            <span class="built_in">return</span> file;</div><div class="line">        &#125; catch (WriterException e) &#123;</div><div class="line">            <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">                logger.debug(<span class="string">"SimpleQRCodeUtil-createQrCode-WriterException:"</span>+e);</div><div class="line">            &#125;</div><div class="line">        &#125; catch (IOException e) &#123;</div><div class="line">            <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">                logger.debug(<span class="string">"SimpleQRCodeUtil-createQrCode-IOException:"</span>+e);</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line"></div><div class="line">        <span class="built_in">return</span> null;</div><div class="line">    &#125;</div><div class="line"></div><div class="line"></div><div class="line">    /**</div><div class="line">     * 简单二维码读取</div><div class="line">     * @param file</div><div class="line">     * @<span class="built_in">return</span></div><div class="line">     */</div><div class="line">    public static Result readQRCode(File file) &#123;</div><div class="line"></div><div class="line">        <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">            logger.debug(<span class="string">"SimpleQRCodeUtil-readQRCode-File:"</span>+file);</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">if</span>(file==null)&#123;</div><div class="line">            file = new File(<span class="string">"D:/QRcode/fish/index.png"</span>);</div><div class="line">        &#125;</div><div class="line"></div><div class="line">        MultiFormatReader formatReader = new MultiFormatReader();</div><div class="line">        BufferedImage image = null;</div><div class="line">        try &#123;</div><div class="line">            image = ImageIO.read(file);</div><div class="line">        &#125; catch (IOException e) &#123;</div><div class="line">            <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">                logger.debug(<span class="string">"SimpleQRCodeUtil-readQRCode-IOException:"</span>+e);</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">        BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));</div><div class="line"></div><div class="line">        HashMap hints = new HashMap();</div><div class="line">        hints.put(EncodeHintType.CHARACTER_SET,<span class="string">"UTF-8"</span>);</div><div class="line">        Result result = null;</div><div class="line">        try &#123;</div><div class="line">            result = formatReader.decode(binaryBitmap,hints);</div><div class="line">        &#125; catch (NotFoundException e) &#123;</div><div class="line">            <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">                logger.debug(<span class="string">"SimpleQRCodeUtil-readQRCode-NotFoundException:"</span>+e);</div><div class="line">            &#125;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">            logger.debug(<span class="string">"SimpleQRCodeUtil-readQRCode-result:"</span>+result);</div><div class="line">        &#125;</div><div class="line">        System.out.println(<span class="string">"解析结果："</span> +result.toString());</div><div class="line">        System.out.println(<span class="string">"二维码时间戳："</span> +result.getTimestamp());</div><div class="line">        System.out.println(<span class="string">"二维码格式类型："</span> +result.getBarcodeFormat());</div><div class="line">        System.out.println(<span class="string">"二维码文本内容："</span> +result.getText());</div><div class="line"></div><div class="line">        <span class="built_in">return</span>  result;</div><div class="line">    &#125;</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">    /**</div><div class="line">     * &lt;span style=<span class="string">"font-size:18px;font-weight:blod;"</span>&gt;ZXing 方式生成二维码&lt;/span&gt;</div><div class="line">     * @param text    &lt;a href=<span class="string">"javascript:void();"</span>&gt;二维码内容&lt;/a&gt;</div><div class="line">     * @param width    二维码宽</div><div class="line">     * @param height    二维码高</div><div class="line">     * @param outPutPath    二维码生成保存路径</div><div class="line">     * @param imageType        二维码生成格式</div><div class="line">     */</div><div class="line">    public static void zxingCodeCreate(String text, int width, int height, String outPutPath, String imageType)&#123;</div><div class="line">        Map&lt;EncodeHintType, String&gt; his = new HashMap&lt;EncodeHintType, String&gt;();</div><div class="line">        //设置编码字符集</div><div class="line">        his.put(EncodeHintType.CHARACTER_SET, <span class="string">"utf-8"</span>);</div><div class="line">        try &#123;</div><div class="line">            //1、生成二维码</div><div class="line">            BitMatrix encode = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height, his);</div><div class="line"></div><div class="line">            //2、获取二维码宽高</div><div class="line">            int codeWidth = encode.getWidth();</div><div class="line">            int codeHeight = encode.getHeight();</div><div class="line"></div><div class="line">            //3、将二维码放入缓冲流</div><div class="line">            BufferedImage image = new BufferedImage(codeWidth, codeHeight, BufferedImage.TYPE_INT_RGB);</div><div class="line">            <span class="keyword">for</span> (int i = 0; i &lt; codeWidth; i++) &#123;</div><div class="line">                <span class="keyword">for</span> (int j = 0; j &lt; codeHeight; j++) &#123;</div><div class="line">                    //4、循环将二维码内容定入图片</div><div class="line">                    image.setRGB(i, j, encode.get(i, j) ? BLACK : WHITE);</div><div class="line">                &#125;</div><div class="line">            &#125;</div><div class="line">            File outPutImage = new File(outPutPath);</div><div class="line">            //如果图片不存在创建图片</div><div class="line">            <span class="keyword">if</span>(!outPutImage.exists())</div><div class="line">                outPutImage.createNewFile();</div><div class="line">            //5、将二维码写入图片</div><div class="line">            ImageIO.write(image, imageType, outPutImage);</div><div class="line">        &#125; catch (WriterException e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">            System.out.println(<span class="string">"二维码生成失败"</span>);</div><div class="line">        &#125; catch (IOException e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">            System.out.println(<span class="string">"生成二维码图片失败"</span>);</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line">    public   static  void  main(String  args[])&#123;</div><div class="line"></div><div class="line">        createQrCode(300,500,<span class="string">"png"</span>,<span class="string">"http://fish_08.oschina.io/"</span>);</div><div class="line">        File  file=new File(<span class="string">"D:/QRcode/fish/index.png"</span>);</div><div class="line">        Result result=readQRCode(file);</div><div class="line">        System.out.println(<span class="string">"result:"</span>+result);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="二维码中嵌入Logo生成工具类QRCodeUtil"><a href="#二维码中嵌入Logo生成工具类QRCodeUtil" class="headerlink" title="二维码中嵌入Logo生成工具类QRCodeUtil"></a>二维码中嵌入Logo生成工具类QRCodeUtil</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div><div class="line">147</div><div class="line">148</div><div class="line">149</div><div class="line">150</div><div class="line">151</div><div class="line">152</div><div class="line">153</div><div class="line">154</div><div class="line">155</div><div class="line">156</div><div class="line">157</div><div class="line">158</div><div class="line">159</div><div class="line">160</div><div class="line">161</div><div class="line">162</div><div class="line">163</div><div class="line">164</div><div class="line">165</div><div class="line">166</div><div class="line">167</div><div class="line">168</div><div class="line">169</div><div class="line">170</div><div class="line">171</div><div class="line">172</div><div class="line">173</div><div class="line">174</div><div class="line">175</div><div class="line">176</div><div class="line">177</div><div class="line">178</div><div class="line">179</div><div class="line">180</div><div class="line">181</div><div class="line">182</div><div class="line">183</div><div class="line">184</div><div class="line">185</div><div class="line">186</div><div class="line">187</div><div class="line">188</div><div class="line">189</div><div class="line">190</div><div class="line">191</div><div class="line">192</div><div class="line">193</div><div class="line">194</div><div class="line">195</div><div class="line">196</div><div class="line">197</div><div class="line">198</div><div class="line">199</div><div class="line">200</div><div class="line">201</div><div class="line">202</div><div class="line">203</div><div class="line">204</div><div class="line">205</div><div class="line">206</div><div class="line">207</div><div class="line">208</div><div class="line">209</div><div class="line">210</div><div class="line">211</div><div class="line">212</div><div class="line">213</div><div class="line">214</div><div class="line">215</div><div class="line">216</div><div class="line">217</div><div class="line">218</div><div class="line">219</div><div class="line">220</div><div class="line">221</div><div class="line">222</div><div class="line">223</div><div class="line">224</div><div class="line">225</div><div class="line">226</div><div class="line">227</div><div class="line">228</div><div class="line">229</div><div class="line">230</div><div class="line">231</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">public class QRCodeUtil &#123;</div><div class="line"></div><div class="line">   private  static Logger logger = LoggerFactory.getLogger(QRCodeUtil.class);</div><div class="line"></div><div class="line">   private static final String CHARSET = <span class="string">"UTF-8"</span>;</div><div class="line"></div><div class="line">   private static final String FORMAT_NAME = <span class="string">"png"</span>;</div><div class="line"></div><div class="line">   // 二维码尺寸</div><div class="line">   private static final int QRCODE_SIZE = 400;</div><div class="line">   // LOGO宽度</div><div class="line">   private static final int WIDTH = 100;</div><div class="line">   // LOGO高度</div><div class="line">   private static final int HEIGHT = 100;</div><div class="line"></div><div class="line"></div><div class="line">   /**</div><div class="line">    * 创建简单二维码图片</div><div class="line">    * @param content</div><div class="line">    * @param imgPath</div><div class="line">    * @param needCompress</div><div class="line">    * @param fileName</div><div class="line">    * @<span class="built_in">return</span></div><div class="line">    */</div><div class="line">   private static BufferedImage createImage(String content, String imgPath, boolean needCompress, String fileName)  &#123;</div><div class="line"></div><div class="line">       Hashtable&lt;EncodeHintType, Object&gt; hints = new Hashtable&lt;EncodeHintType, Object&gt;();</div><div class="line">       hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);</div><div class="line">       hints.put(EncodeHintType.CHARACTER_SET, CHARSET);</div><div class="line">       hints.put(EncodeHintType.MARGIN, 1);</div><div class="line">       BitMatrix bitMatrix = null;</div><div class="line">       try &#123;</div><div class="line">           bitMatrix = new MultiFormatWriter().encode(content,</div><div class="line">                   BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);</div><div class="line">       &#125; catch (WriterException e) &#123;</div><div class="line">           <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">               logger.debug(<span class="string">"QRCodeUtil-createImage-WriterException:"</span>+e);</div><div class="line">           &#125;</div><div class="line">       &#125;</div><div class="line">       int width = bitMatrix.getWidth();</div><div class="line">       int height = bitMatrix.getHeight();</div><div class="line">       BufferedImage image = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);</div><div class="line">       <span class="keyword">for</span> (int x = 0; x &lt; width; x++) &#123;</div><div class="line">           <span class="keyword">for</span> (int y = 0; y &lt; height; y++) &#123;</div><div class="line">               image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);</div><div class="line">           &#125;</div><div class="line">       &#125;</div><div class="line">       <span class="keyword">if</span> (imgPath == null || <span class="string">""</span>.equals(imgPath)) &#123;</div><div class="line">           <span class="built_in">return</span> image;</div><div class="line">       &#125;</div><div class="line">       // 插入图片</div><div class="line">       try &#123;</div><div class="line">           QRCodeUtil.insertImage(image, imgPath, needCompress,fileName);</div><div class="line">       &#125; catch (Exception e) &#123;</div><div class="line">           <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">               logger.debug(<span class="string">"QRCodeUtil-createImage-Exception:"</span>+e);</div><div class="line">           &#125;</div><div class="line">       &#125;</div><div class="line">       <span class="built_in">return</span> image;</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    *  在简单二维码图片中插入LOGO</div><div class="line">    * @param <span class="built_in">source</span> 二维码图片</div><div class="line">    * @param imgPath LOGO图片地址</div><div class="line">    * @param needCompress 是否压缩</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   private static void insertImage(BufferedImage <span class="built_in">source</span>, String imgPath, boolean needCompress,String fileName) throws Exception &#123;</div><div class="line">       File file = new File(imgPath);</div><div class="line">       <span class="keyword">if</span> (!file.exists()) &#123;</div><div class="line">           <span class="keyword">if</span>(logger.isDebugEnabled())&#123;</div><div class="line">               logger.debug(<span class="string">"QRCodeUtil-insertImage-file.exists():"</span>+imgPath+<span class="string">"   该文件不存在！"</span>);</div><div class="line">           &#125;</div><div class="line">           <span class="built_in">return</span>;</div><div class="line">       &#125;</div><div class="line">       Image src = ImageIO.read(new File(imgPath));</div><div class="line">       int width = src.getWidth(null);</div><div class="line">       int height = src.getHeight(null);</div><div class="line">       <span class="keyword">if</span> (needCompress) &#123; // 压缩LOGO</div><div class="line">           <span class="keyword">if</span> (width &gt; WIDTH) &#123;</div><div class="line">               width = WIDTH;</div><div class="line">           &#125;</div><div class="line">           <span class="keyword">if</span> (height &gt; HEIGHT) &#123;</div><div class="line">               height = HEIGHT;</div><div class="line">           &#125;</div><div class="line">           Image image = src.getScaledInstance(width, height,</div><div class="line">                   Image.SCALE_SMOOTH);</div><div class="line">           BufferedImage tag = new BufferedImage(width, height,</div><div class="line">                   BufferedImage.TYPE_INT_RGB);</div><div class="line">           Graphics g = tag.getGraphics();</div><div class="line">           g.drawImage(image, 0, 0, null); // 绘制缩小后的图</div><div class="line">           g.dispose();</div><div class="line">           src = image;</div><div class="line">       &#125;</div><div class="line">       // 插入LOGO</div><div class="line">       Graphics2D graph = source.createGraphics();</div><div class="line">       int x = (QRCODE_SIZE - width) / 2;</div><div class="line">       int y = (QRCODE_SIZE - height) / 2;</div><div class="line">       graph.drawImage(src, x, y, width, height, null);</div><div class="line">       Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);</div><div class="line">       graph.setStroke(new BasicStroke(3f));</div><div class="line">       graph.draw(shape);</div><div class="line">       graph.dispose();</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 生成二维码(内嵌LOGO)</div><div class="line">    * @param content      内容</div><div class="line">    * @param imgPath      LOGO地址</div><div class="line">    * @param destPath     存放目录</div><div class="line">    * @param needCompress 是否压缩LOGO</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static void encode(String content, String imgPath, String destPath,boolean needCompress,String fileName) throws Exception &#123;</div><div class="line">       BufferedImage image = QRCodeUtil.createImage(content, imgPath, needCompress,fileName);</div><div class="line">       mkdirs(destPath);</div><div class="line">       ImageIO.write(image, FORMAT_NAME, new File(destPath+<span class="string">"/"</span>+fileName));</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 当文件夹不存在时，mkdirs会自动创建多层目录，区别于mkdir．(mkdir如果父目录不存在则会抛出异常)</div><div class="line">    * @author lanyuan</div><div class="line">    * Email: mmm333zzz520@163.com</div><div class="line">    * @date 2013-12-11 上午10:16:36</div><div class="line">    * @param destPath 存放目录</div><div class="line">    */</div><div class="line">   public static void mkdirs(String destPath) &#123;</div><div class="line">       File file =new File(destPath);</div><div class="line">       //当文件夹不存在时，mkdirs会自动创建多层目录，区别于mkdir．(mkdir如果父目录不存在则会抛出异常)</div><div class="line">       <span class="keyword">if</span> (!file.exists() &amp;&amp; !file.isDirectory()) &#123;</div><div class="line">           file.mkdirs();</div><div class="line">       &#125;</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 生成二维码(内嵌LOGO)</div><div class="line">    * @param content    内容</div><div class="line">    * @param imgPath    LOGO地址</div><div class="line">    * @param destPath   存储地址</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static void encode(String content, String imgPath, String destPath,String fileName) throws Exception &#123;</div><div class="line">       QRCodeUtil.encode(content, imgPath, destPath, <span class="literal">false</span>,fileName);</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 生成二维码</div><div class="line">    * @param content 内容</div><div class="line">    * @param destPath 存储地址</div><div class="line">    * @param needCompress 是否压缩LOGO</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static void encode(String content, String destPath, boolean needCompress,String fileName) throws Exception &#123;</div><div class="line">       QRCodeUtil.encode(content, null, destPath, needCompress,fileName);</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 生成简单二维码</div><div class="line">    * @param content  内容</div><div class="line">    * @param destPath 存储地址</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static void encode(String content, String destPath,String fileName) throws Exception &#123;</div><div class="line">       QRCodeUtil.encode(content, null, destPath, <span class="literal">false</span>,fileName);</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 生成内嵌图片二维码(内嵌LOGO)</div><div class="line">    * @param content 内容</div><div class="line">    * @param imgPath LOGO地址</div><div class="line">    * @param output  输出流</div><div class="line">    * @param needCompress 是否压缩LOGO</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static void encode(String content, String imgPath, OutputStream output, boolean needCompress,String fileName) throws Exception &#123;</div><div class="line">       BufferedImage image = QRCodeUtil.createImage(content,imgPath,needCompress,fileName);</div><div class="line">       ImageIO.write(image, FORMAT_NAME, output);</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 生成简单二维码</div><div class="line">    * @param content 内容</div><div class="line">    * @param output  输出流</div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static void encode(String content, OutputStream output, String fileName)</div><div class="line">           throws Exception &#123;</div><div class="line">       QRCodeUtil.encode(content, null, output, <span class="literal">false</span>,fileName);</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 解析二维码</div><div class="line">    * @param file 二维码图片</div><div class="line">    * @<span class="built_in">return</span></div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static String decodeByFile(File file) throws Exception &#123;</div><div class="line">       BufferedImage image;</div><div class="line">       image = ImageIO.read(file);</div><div class="line">       <span class="keyword">if</span> (image == null) &#123;</div><div class="line">           <span class="built_in">return</span> null;</div><div class="line">       &#125;</div><div class="line">       BufferedImageLuminanceSource <span class="built_in">source</span> = new BufferedImageLuminanceSource(</div><div class="line">               image);</div><div class="line">       BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(<span class="built_in">source</span>));</div><div class="line">       Result result;</div><div class="line">       Hashtable&lt;DecodeHintType, Object&gt; hints = new Hashtable&lt;DecodeHintType, Object&gt;();</div><div class="line">       hints.put(DecodeHintType.CHARACTER_SET, CHARSET);</div><div class="line">       result = new MultiFormatReader().decode(bitmap, hints);</div><div class="line">       String resultStr = result.getText();</div><div class="line">       <span class="built_in">return</span> resultStr;</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   /**</div><div class="line">    * 解析二维码</div><div class="line">    * @param path  二维码图片地址</div><div class="line">    * @<span class="built_in">return</span></div><div class="line">    * @throws Exception</div><div class="line">    */</div><div class="line">   public static String decodeByPath(String path) throws Exception &#123;</div><div class="line">       <span class="built_in">return</span> QRCodeUtil.decodeByFile(new File(path));</div><div class="line">   &#125;</div><div class="line"></div><div class="line">   public static void main(String[] args) throws Exception &#123;</div><div class="line"></div><div class="line">       String text = <span class="string">"http://fish_08.oschina.io/"</span>;</div><div class="line">       QRCodeUtil.encode(text,<span class="string">"D:/QRCode/fish/logo.jpg"</span>,<span class="string">"D:/QRCode/fish"</span>, <span class="literal">true</span>,<span class="string">"houzi.png"</span>);</div><div class="line"></div><div class="line">   &#125;</div></pre></td></tr></table></figure>
        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-06-28T08:16:51.528Z" itemprop="dateUpdated">2017年6月28日 16:16</time>
</span><br>


        如要转载请注明出处：<a href="/2017/06/23/QRcode/" target="_blank" rel="external">http://fish_08.oschina.io/2017/06/23/QRcode/</a>
    </div>
    <footer>
        <a href="http://fish_08.oschina.io">
            <img src="/img/avatar.jpg" alt="于亮">
            于亮
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ZXing/">ZXing</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/二维码/">二维码</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://fish_08.oschina.io/2017/06/23/QRcode/&title=《zxing后台二维码生成和解析类库》 — 尼古拉斯-鱼丸博客&pic=http://fish_08.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://fish_08.oschina.io/2017/06/23/QRcode/&title=《zxing后台二维码生成和解析类库》 — 尼古拉斯-鱼丸博客&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://fish_08.oschina.io/2017/06/23/QRcode/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《zxing后台二维码生成和解析类库》 — 尼古拉斯-鱼丸博客&url=http://fish_08.oschina.io/2017/06/23/QRcode/&via=http://fish_08.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://fish_08.oschina.io/2017/06/23/QRcode/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/06/26/mapreduce/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">MapReduce</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/06/21/sequence/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">分布式ID生成器-Sequence</h4>
      </a>
    </div>
  
</nav>



    







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢包子~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.png" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.png" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="http://fish_08.oschina.io/" target="_blank">yuliang</a></span>
            <span>尼古拉斯-鱼丸博客 &copy; 2015 - 2018</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://fish_08.oschina.io/2017/06/23/QRcode/&title=《zxing后台二维码生成和解析类库》 — 尼古拉斯-鱼丸博客&pic=http://fish_08.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://fish_08.oschina.io/2017/06/23/QRcode/&title=《zxing后台二维码生成和解析类库》 — 尼古拉斯-鱼丸博客&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://fish_08.oschina.io/2017/06/23/QRcode/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《zxing后台二维码生成和解析类库》 — 尼古拉斯-鱼丸博客&url=http://fish_08.oschina.io/2017/06/23/QRcode/&via=http://fish_08.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://fish_08.oschina.io/2017/06/23/QRcode/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



</script>

<script src="/js/main.min.js?v=1.6.7"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="/js/search.min.js?v=1.6.7" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>


</body>
</html>
